﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CuaHangLego.Model
{
    public class HoaDon : BaseModel
    {
        public int MaSo { get; set; }
        public DateTime ThoiGian { get; set; }
        private IList<CTHD> dsCTHD;
        public IList<CTHD> DsCTHD
        {
            get
            {
                if (this.dsCTHD == null) this.dsCTHD = lazy.Value;
                return this.dsCTHD;
            }
            set
            {
                this.dsCTHD = value;
            }
        }
        public bool DaThanhToan { get; set; }

        public readonly Lazy<IList<CTHD>> lazy;

        public HoaDon()
            : base()
        {
            this.lazy = new Lazy<IList<CTHD>>(() => GetCTHDs());
        }

        public HoaDon(int MaSo, DateTime ThoiGian, IList<CTHD> DsCTHD, bool DaThanhToan)
            : base()
        {
            this.MaSo = MaSo;
            this.ThoiGian = ThoiGian;
            this.DsCTHD = DsCTHD;
            this.DaThanhToan = DaThanhToan;
        }

        public HoaDon(int MaSo, DateTime ThoiGian) 
            : this(MaSo, ThoiGian, new List<CTHD>(), false)
        {

        }

        protected virtual IList<CTHD> GetCTHDs()
        {
            return null;
        }
    }
}
